package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.util.Utils;
import java.util.Calendar;

public class TIME extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 3)
      return Primitive.ERROR_NAME;
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.set(11, Utils.objectToNumber(paramArrayOfObject[0], false).intValue());
    localCalendar.set(12, Utils.objectToNumber(paramArrayOfObject[1], false).intValue());
    localCalendar.set(13, Utils.objectToNumber(paramArrayOfObject[2], false).intValue());
    return localCalendar.getTime();
  }

  public Function.Type getType()
  {
    return Function.DATETIME;
  }

  public String getCN()
  {
    return "TIME(hour,minute,second): 返回代表指定时间的小数。介于0:00:00（12:00:00 A.M.）与23:59:59（11:59:59 P.M.）之间的时间可返回0到0.99999999之间的对应数值。\nHour:介于0到23之间的数。\nMinute:介于0到59之间的数。\nSecond:介于0到59之间的数。\n示例:\nTIME(14,40,0)等于2:40 PM。\nTIME(19,43,24)等于7:43 PM。";
  }

  public String getEN()
  {
    return "TIME(hour,minute,second): Returns the decimal number for a particular time. The decimal number returned by TIME is a value ranging from 0 (zero) to 0.99999999, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).\nHour is a number from 0 (zero) to 23 representing the hour.\nMinute is a number from 0 to 59 representing the minute.\nSecond is a number from 0 to 59 representing the second.\nExample:\n   TIME(14,40,0) = 2:40 PM\n   TIME(19,43,24) = 7:43 PM";
  }
}